"""
   -*- coding: utf-8 -*-
   @Time    : 2021/4/23 19:06
   @Author  : 狠欢
   @File    : 正则爬取三创图片.py
   @Software: PyCharm
"""

import re
import requests
import time
# 模拟浏览器
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36"}

# 1.获取网页内容


response = requests.get("https://www.sanchuangedu.cn/", headers=headers)
html = response.text
# print(html)
html_url = response.url

result1 = re.findall(r'src="(.*?(?:\.jepg|\.png|\.jpg))"', html)
for i in result1:
    aaaa = "https://www.sanchuangedu.cn"+i
    # print(aaaa)
    bbbb =aaaa.split("/")[-1]
    print(bbbb)
    time.sleep(1)
    response1 = requests.get(aaaa, headers=headers)
    with open('./img' + '/'+bbbb, "wb")as f:
        f.write(response1.content)







